/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.gis.eemc.web;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import net.gis.eemc.service.FacultyServiceImpl;
import net.gis.eemc.domain.Faculty;

/**
 *
 * @author Sergey
 */
@ManagedBean(name = "editFacultyBean")
@ViewScoped
public class EditFacultyBean {

    Integer id = null;
    String title = null;
    String shortName = null;
    private FacultyServiceImpl facSrv = null;

    /** Creates a new instance of EditFacultyBean */
    public EditFacultyBean() {
        facSrv = new FacultyServiceImpl();

        FacesContext context = FacesContext.getCurrentInstance();
        id = new Integer(context.getExternalContext().getRequestParameterMap().get("id"));
        title = context.getExternalContext().getRequestParameterMap().get("title");
        shortName = context.getExternalContext().getRequestParameterMap().get("shortName");
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public void update() {
        if (id != null && title != null && shortName != null) {
            facSrv.update(new Faculty(id, title, shortName));
        }
    }
}
